package br.ucb.sigplan.crud;

import java.util.List;


import br.ucb.sigplan.beans.Disciplina;
import br.ucb.sigplan.dao.DisciplinaDAO;
import br.ucb.sigplan.dao.impl.DisciplinaDAOImpl;
import br.ucb.sigplan.exception.DAOException;

public class DisciplinaCrud {
	private static DisciplinaDAO disciplinaDAO;
	
	private DisciplinaCrud() {
		
	}
	
	public static DisciplinaDAO getDisciplinaDAO() {
		if (disciplinaDAO == null) {
			disciplinaDAO = new DisciplinaDAOImpl();
		}
		return disciplinaDAO;
	}
	
	public static void insert(Disciplina disciplina) throws DAOException{
		getDisciplinaDAO().insert(disciplina);
	}
	
	public static List<Disciplina> findAll(){
		return getDisciplinaDAO().findAll();
	}
	
	public static Disciplina findById(Integer iddisciplina){
		return getDisciplinaDAO().findById(iddisciplina);
	}
	
	public static boolean isDisciplinaCadastrada(Integer codigoCurriculo, String nome) {
		return getDisciplinaDAO().isDisciplinaCadastrada(codigoCurriculo, nome);
	}

	public static void delete(Integer idDisciplina) throws DAOException{
		getDisciplinaDAO().delete(idDisciplina);
	}
	
	public static void update(Disciplina disciplina) throws DAOException{
		getDisciplinaDAO().update(disciplina);
	}
}
